<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script type="module">
        import Graph from './Graph.js';
        import {depthFirstSearch,DFS} from './DepthFirstSearch.js';

        const graph = new Graph();
        const myVertices = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I'];
        // 添加顶点
        for (let i = 0; i < myVertices.length; i++) {
            graph.addVertex(myVertices[i]);
        }
        // 初始化边
        graph.addEdge('A', 'B');
        graph.addEdge('A', 'C');
        graph.addEdge('A', 'D');
        graph.addEdge('C', 'D');
        graph.addEdge('C', 'G');
        graph.addEdge('D', 'G');
        graph.addEdge('D', 'H');
        graph.addEdge('B', 'E');
        graph.addEdge('B', 'F');
        graph.addEdge('E', 'I');

        // 输出图
        console.log(graph.toString());

        // 输出已经被完全探索过的顶点的名字
        const printVertex = (value) => console.log('Visited vertex: ' + value);
        depthFirstSearch(graph, printVertex);

        console.log(DFS(graph));
    </script>
</body>
</html>